import Mock from 'mockjs2'
import { builder, getBody } from '../../util'
import { gridApi } from '@/api/demo/grid.js'

// 表格数据
const gridData = Mock.mock({
  'totalCount': 200,
  'data|10': [{
    'id|+1': 1,
    'name': '@cname',
    'idCard': '@integer(510800000000000000, 999999999999999999)',
    'date': "@date('yyyy-MM-dd')",
    'address': '@cword(20,50)',
    'education': '@cword(2,4)'
  }]
})

/**
 * 获取表格数据
 */
const getGridData = (options) => {
  console.log(options)
  return builder(gridData, '', 200)
}

/**
 * 删除表格数据
 */
const deleteGridData = (options) => {
  const body = getBody(options)
  console.log('mock: body', body)

  return builder({}, '', 200)
}

/**
 * 新增表格数据
 */
const addGridData = (options) => {
  const body = getBody(options)
  console.log('mock: body', body)

  return builder({}, '', 200)
}

/**
 * 编辑表格数据
 */
const editGridData = (options) => {
  const body = getBody(options)
  console.log('mock: body', body)

  return builder({}, '', 200)
}

Mock.mock(gridApi.getGridData, 'post', getGridData)
Mock.mock(gridApi.addGridData, 'post', addGridData)
Mock.mock(gridApi.editGridData, 'post', editGridData)
Mock.mock(gridApi.deleteGridData, 'post', deleteGridData)
